<template>
  <div>路由a页面</div>
  <button @click="jump">btn</button>
  <button @click="get">btn2</button>
</template>

<script>
import { useRouter, useRoute } from "vue-router";
export default {
  setup() {
    // useRouter和useRoute都必须写在setup的顶层

    // 执行useRouter函数可以返回路由实例
    const router = useRouter();
    // 执行useRoute函数可以返回当前路由信息
    const route = useRoute();

    const jump = () => {
      router.push("/b");
    };
    const get = () => {
      console.log(route.params);
    };

    return {
      jump,
      get,
    };
  },
};
</script>

<style lang="less" scoped></style>
